export default function registerPolyline(lf) {
  lf.register('polyline', ({ PolylineEdge, PolylineEdgeModel }) => {
    class ConnnectionModel extends PolylineEdgeModel {
      constructor(data, graphModel) {
        super(data, graphModel)
        this.properties = data.properties || {}
      }

      getEdgeStyle() {
        const style = super.getEdgeStyle()
        const { properties } = this
        const { nodeStyle } = properties
        if (properties && nodeStyle) {
          if (nodeStyle.fill) {
            style.fill = 'transparent'
          }
          if (nodeStyle.stroke) {
            style.stroke = nodeStyle.stroke
          }
        }

        return style
      }
    }

    return {
      view: PolylineEdge,
      model: ConnnectionModel,
    }
  })
}
